﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace MS.InformationManagement.DocumentIDServiceApp
{
    [Flags]
    public enum ExecuteOptions
    {
        None = 0x0,
        AsProcess = 0x1,
        // Async = 0x2,
    }

    public sealed class DocumentIDServiceClient
    {
        private SPServiceContext _serviceContext;

        public DocumentIDServiceClient(SPServiceContext serviceContext)
        {
            if (serviceContext == null)
                throw new ArgumentNullException("serviceContext");

            this._serviceContext = serviceContext;
        }

        public void AddDocumentIDBank(string bankName, ExecuteOptions options)
        {
            DocumentIDServiceApplicationProxy.Invoke(_serviceContext, proxy => proxy.AddDocumentIDBank(bankName, options));
        }

        public void DeleteDocumentIDBank(string bankName, ExecuteOptions options)
        {
            DocumentIDServiceApplicationProxy.Invoke(_serviceContext, proxy => proxy.DeleteDocumentIDBank(bankName, options));
        }

        public void ResetDocumentIDBank(string bankName, ExecuteOptions options)
        {
            DocumentIDServiceApplicationProxy.Invoke(_serviceContext, proxy => proxy.ResetDocumentIDBank(bankName, options));
        }

        public int GetNextDocumentID(string bankName, ExecuteOptions options)
        {
            int result = 0;
            DocumentIDServiceApplicationProxy.Invoke(_serviceContext, proxy => result = proxy.GetNextDocumentID(bankName, options));
            return (result);
        }
    }
}
